package caiziyou.com.designpattern.factory.simple.pizzastore;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 违反了OCP原则，推展需要修改客户端代码
 * @author Administrator
 *
 */
public class OrderPizza {

	public OrderPizza() {
		super();
		Pizza pizza = null;
		String orderType = null;
		do {
			orderType = getType();
			if(orderType.equals("greek")) {
				pizza = new GeekPizza();
				pizza.setName("希腊披萨");
			}else if (orderType.equals("cheese")) {
				pizza = new CheesePizza();
				pizza.setName("奶酪披萨");
			}else {
				break;
			}
			pizza.prepare();
			pizza.bake();
			pizza.cut();
			pizza.box();
		}while(true);
	}

	public String getType() {
		
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		try {
			System.out.println("input pizza type:");
			return bufferedReader.readLine();
		} catch (IOException e) {
			
			return "";
		}
	}
}
